//
//  BaseViewController.m
//  QuickCure
//
//  Created by 马文星 on 16/4/28.
//  Copyright © 2016年 Demos. All rights reserved.
//

#import "BaseViewController.h"

@interface BaseViewController ()

@end

@implementation BaseViewController

- (void)viewDidLoad {
    [super viewDidLoad];

    //左返回按钮
    [self setupLeftButtonItem];
    
 }

/*!
 *  根据StoryBoard 来切换控制器 ********************************
 */
-(UIViewController *)showInitialVCWithSBName:(NSString *)sbName identifier:(NSString *)identifier{

    UIStoryboard *sb = [UIStoryboard storyboardWithName:sbName bundle:nil];
    
  UIViewController *newVC =   [sb instantiateViewControllerWithIdentifier:identifier];

    return newVC;
}
/*!
 *  JASidePanelController 侧滑 ********************************
 */
- (UINavigationController *)centerNavigationController
{
    return (UINavigationController *)self.sidePanelController.centerPanel;
}
- (UIViewController *)leftMenuViewController
{
    return (UIViewController *)self.sidePanelController.leftPanel;
}

-(void)jump2OtherViewControllerByMenu:(UIViewController *)oneVC{
    //显示中间
    [self.sidePanelController showCenterPanelAnimated:YES];
    
    //push到下一个VC
    [[self centerNavigationController] pushViewController:oneVC animated:NO];
}

/*!
 *  更换左返回按钮 *********************************************
 */
-(void)setupLeftButtonItem{

    UIButton *leftBtn = [[UIButton alloc] initWithFrame:CGRectMake(0, 0, 40, 40)];
    
    [leftBtn setImage:[UIImage imageNamed:@"JianTou"] forState:UIControlStateNormal];
    [leftBtn addTarget:self action:@selector(goBack) forControlEvents:UIControlEventTouchUpInside];
    
    self.navigationItem.leftBarButtonItem = [[UIBarButtonItem alloc] initWithCustomView:leftBtn];

}

#pragma mark  - Actions ********************************
-(void)goBack{

    [self.navigationController popToRootViewControllerAnimated:YES];
}

@end
